package com.nantong.common.core.enums.commonEnums;

import lombok.AllArgsConstructor;
import lombok.Getter;


/**
 * 用户类型
 *
 * @author Lion Li
 */
@Getter
@AllArgsConstructor
public enum UserType {

    /**
     * 后台系统用户
     */
    SYS_USER(1, "sys_user"),

    /**
     * 移动客户端用户
     */
    APP_USER(2, "app_user");

    private final Integer code;


    private final String desc;

    /**
     * 用户类型标识（用于 token、权限识别等）
     */

    public static UserType getCode(Integer code) {
        if (code != null) {
            for (UserType userType : values()) {
                if (userType.getCode().equals(code)) {
                    return userType;
                }
            }
        }
        throw new RuntimeException("'UserType' not found By " + code);
    }
}
